var app = new Framework7({
  // App root element
  root: '#app',
  panel: {
    swipe: 'left',
  },
  // Add default routes
  routes: [
    {
      path: '/messages',
      url: 'messages.html',
    },
    {
      path: '/activeState',
      url: 'activeState.html',
    },
    {
      path: '/babyPhotos',
      url: 'babyPhotos.html',
    },
    {
      path: '/childrearing',
      url: 'childrearing.html',
    },
    {
      path: '/login',
      url: 'login.html',
    },
    {
      path: '/newPerson',
      url: 'newPerson.html',
    },
    {
      path: '/patriarchInfo',
      url: 'patriarchInfo.html',
    },
    {
      path: '/people',
      url: 'people.html',
    },
    {
      path: '/photos',
      url: 'photos.html',
    }
  ],
  // ... other parameters
});

var mainView = app.views.create('.view-main');

var $$ = Dom7;

// Tab选择
$$(".toolbar a.link").on("click", function(){
    $$(this).addClass("active").siblings(".toolbar a.link").removeClass("active");
});

$$(".tabbar .tab-link").on("click", function(){
    $$(this).addClass("tab-link-active").siblings(".tabbar .tab-link").removeClass("tab-link-active");
    var curindex = $$(this).index();
    var curselector = "#tab-" + curindex;
    $$(curselector).addClass("tab-active").siblings().removeClass("tab-active");
});

//动态加载数据集
var itemsPerLoad = 3; //每一次加载数量
var maxItems = 10; //最大加载数量
function ScrollExcute(selectorBox, selectorItemBox, selectorItem, htmlstr){
    // 正在加载标志
    var allowInfinite = true;
    // 最后一个加载的index
    var lastItemIndex = $$(selectorItem).length;

    // 监听滚动事件
    $$('.infinite-scroll-content').on('infinite', function () {
        if (!allowInfinite) return;

        allowInfinite = false;

        setTimeout(function () {
            allowInfinite = true;

            if (lastItemIndex >= maxItems) {
                // 超过最大加载数量
                app.infiniteScroll.destroy('.infinite-scroll-content');
                $$('.infinite-scroll-preloader').remove();
                $$(selectorBox).append('<div class="loaded">加载完毕</div>');
                return;
            }

            $$(selectorItemBox).append(htmlstr);
            lastItemIndex = $$(selectorItem).length;
        }, 1000);
    });
}








